import cv2
import numpy
import os

randomByteArray = bytearray(os.urandom(120000))
flatNumpyArray = numpy.array(randomByteArray)

grayImg = flatNumpyArray.reshape(300, 400)
cv2.imwrite("randomGray.png", grayImg)

bgrImg = flatNumpyArray.reshape(100, 400, 3)
cv2.imwrite("randomBGR.png", bgrImg)